package br.unicamp.ic.inf312.arena.testeunitario.persistencia.dao;

import java.sql.SQLException;
import java.util.Collection;

import br.unicamp.ic.inf312.arena.modelo.vendas.Bilhete;
import br.unicamp.ic.inf312.arena.persistencia.dao.IBilheteDAO;
import br.unicamp.ic.inf312.framework.persistencia.DataAccessObjectFactory;
import br.unicamp.ic.inf312.framework.teste.DAOBaseTestCase;

public class BilheteDAOMySQLTest extends DAOBaseTestCase {
	private static final String PERSISTENCIA_PROPERTIES = "br/unicamp/ic/inf312/persistencia.properties";

	private IBilheteDAO daoBilhete = null;

	protected void setUp() throws Exception {
		super.setUp();
		DataAccessObjectFactory.getInstance(PERSISTENCIA_PROPERTIES);
		daoBilhete = (IBilheteDAO) DataAccessObjectFactory
				.getImpl(IBilheteDAO.class);
	}

	public void testObterBilhetes() {
		try {
			Collection<Bilhete> bilhetes = daoBilhete.obterBilhetes(01L);
			System.out.println("\t Bilhetes: " + bilhetes);
			assertNotNull(bilhetes);
		} catch (SQLException sqlErr) {
			sqlErr.printStackTrace();
			System.err.println(sqlErr.getCause());
			assertFalse(true);
		} catch (Exception err) {
			err.printStackTrace();
			System.err.println(err.getCause());
			assertFalse(true);
		}
	}

	protected void tearDown() throws Exception {
		super.tearDown();
		daoBilhete = null;
	}	
}